home *** CD-ROM | disk | FTP | other *** search
/ All for Cell Phones: Sony Ericsson / Sony-Ericsson 2004.iso / Java / Midpman / midpman.jar / mmCanvas.class (.txt) < prev   
Encoding:
Java Class File  |  2001-07-26  |  16.9 KB  |  666 lines

  1. import java.io.IOException;
  2. import javax.microedition.lcdui.Canvas;
  3. import javax.microedition.lcdui.Command;
  4. import javax.microedition.lcdui.Displayable;
  5. import javax.microedition.lcdui.Font;
  6. import javax.microedition.lcdui.Graphics;
  7. import javax.microedition.lcdui.Image;
  8.  
  9. class mmCanvas extends Canvas implements Runnable {
  10.    // $FF: renamed from: i int
  11.    int field_0;
  12.    // $FF: renamed from: j int
  13.    int field_1;
  14.    // $FF: renamed from: k int
  15.    int field_2;
  16.    // $FF: renamed from: l int
  17.    int field_3;
  18.    int seed = 1;
  19.    int state = 0;
  20.    long nextTime;
  21.    long now;
  22.    Image maze;
  23.    Image buf;
  24.    Image mazebuf;
  25.    Image[] imgs = new Image[27];
  26.    // $FF: renamed from: bg javax.microedition.lcdui.Graphics
  27.    Graphics field_4;
  28.    // $FF: renamed from: mg javax.microedition.lcdui.Graphics
  29.    Graphics field_5;
  30.    Command startCommand;
  31.    Command pauseCommand;
  32.    // $FF: renamed from: pX int
  33.    int field_6;
  34.    // $FF: renamed from: pY int
  35.    int field_7;
  36.    int pDir;
  37.    int pLook;
  38.    int pCount;
  39.    int pState;
  40.    // $FF: renamed from: mX int
  41.    int field_8;
  42.    // $FF: renamed from: mY int
  43.    int field_9;
  44.    int wantDir;
  45.    int dots;
  46.    int lives;
  47.    int level;
  48.    int eatCount;
  49.    // $FF: renamed from: gX int[]
  50.    int[] field_10 = new int[3];
  51.    // $FF: renamed from: gY int[]
  52.    int[] field_11 = new int[3];
  53.    int[] gDir = new int[3];
  54.    int[] gState = new int[3];
  55.    int[] gCount = new int[3];
  56.    int[] gLook = new int[3];
  57.    int[] sLook = new int[4];
  58.    // $FF: renamed from: sX int[]
  59.    int[] field_12 = new int[4];
  60.    // $FF: renamed from: sY int[]
  61.    int[] field_13 = new int[4];
  62.    int[] sCount = new int[4];
  63.    // $FF: renamed from: w int
  64.    int field_14;
  65.    // $FF: renamed from: h int
  66.    int field_15;
  67.    int counter = 0;
  68.    int oldState;
  69.    int speed;
  70.    int targetX;
  71.    int targetY;
  72.    int bestVal;
  73.    int bestDir;
  74.    int randomness;
  75.    // $FF: renamed from: f javax.microedition.lcdui.Font
  76.    Font field_16 = Font.getFont(0, 0, 0);
  77.    char[] scoreChars = new char[6];
  78.    char[] levelChars = new char[2];
  79.    // $FF: renamed from: fH int
  80.    int field_17;
  81.    // $FF: renamed from: fW int
  82.    int field_18;
  83.    // $FF: renamed from: lW int
  84.    int field_19;
  85.    String[] various = new String[]{"Karl H├╢rnell presents", "The Bad Guys:", "Bill", "Paul", "Steve"};
  86.    String dummyScore = "00000";
  87.    String dummyLevel = "00";
  88.    // $FF: renamed from: dx int[]
  89.    final int[] field_20 = new int[]{0, 0, 0, -1, 1};
  90.    // $FF: renamed from: dy int[]
  91.    final int[] field_21 = new int[]{0, -1, 1, 0, 0};
  92.    final int[] offsX = new int[]{-6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -5, -6, -6, -6, -7, -7, -7, -7};
  93.    final int[] offsY = new int[]{-2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, 0, -2, -2, -2, 0, 0, 0, 0};
  94.    final int[] bonuses = new int[]{8, 1, 2, 4};
  95.    final int[] dPos = new int[]{0, -31, 31, -1, 1};
  96.    int[] map = new int[]{8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 8, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 8, 8, 8, 8, 8, 1, 8, 8, 8, 8, 1, 8, 8, 8, 8, 8, 1, 8, 8, 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 8, 8, 1, 8, 8, 1, 8, 8, 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1, 8, 8, 1, 8, 8, 1, 8, 8, 8, 8, 8, 8, 8, 8, 1, 8, 8, 1, 8, 8, 1, 8, 8, 8, 8, 8, 8, 8, 1, 1, 1, 1, 1, 1, 8, 8, 1, 1, 1, 1, 8, 8, 1, 1, 1, 1, 8, 8, 1, 1, 1, 1, 1, 1, 8, 8, 8, 8, 8, 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1, 8, 8, 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1, 8, 8, 8, 8, 8, 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1, 8, 8, 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1, 8, 8, 8, 8, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8};
  97.    Thread runner;
  98.    // $FF: renamed from: x0 int
  99.    int field_22;
  100.    // $FF: renamed from: y0 int
  101.    int field_23;
  102.  
  103.    public mmCanvas(Command var1, Command var2) {
  104.       this.startCommand = var1;
  105.       this.pauseCommand = var2;
  106.  
  107.       try {
  108.          this.maze = Image.createImage("/pics/pacmaze.png");
  109.  
  110.          for(this.field_0 = 0; this.field_0 < 27; ++this.field_0) {
  111.             this.imgs[this.field_0] = Image.createImage("/pics/img" + this.field_0 + ".png");
  112.          }
  113.       } catch (IOException var4) {
  114.       }
  115.  
  116.       this.field_14 = ((Canvas)this).getWidth();
  117.       this.field_15 = ((Canvas)this).getHeight();
  118.       if (this.field_14 > 112) {
  119.          this.field_22 = (this.field_14 - 112) / 2;
  120.          this.field_14 = 112;
  121.       }
  122.  
  123.       if (this.field_15 > 133) {
  124.          this.field_23 = (this.field_15 - 133) / 2;
  125.          this.field_15 = 133;
  126.       }
  127.  
  128.       this.buf = Image.createImage(this.field_14, this.field_15);
  129.       this.mazebuf = Image.createImage(112, 124);
  130.       this.field_4 = this.buf.getGraphics();
  131.       this.field_5 = this.mazebuf.getGraphics();
  132.       this.field_4.setColor(0, 0, 0);
  133.       this.field_4.fillRect(0, 0, this.field_14, this.field_15);
  134.       this.field_16 = Font.getFont(0, 0, 0);
  135.       this.field_17 = this.field_16.getHeight() - 1;
  136.       if (this.field_17 > 10) {
  137.          this.field_16 = Font.getFont(0, 0, 8);
  138.          this.field_17 = this.field_16.getHeight() - 1;
  139.          if (this.field_17 > 11) {
  140.             this.field_17 = 11;
  141.          }
  142.       }
  143.  
  144.       this.field_4.setFont(this.field_16);
  145.       this.field_5.setFont(this.field_16);
  146.       this.field_18 = this.field_16.stringWidth(this.dummyScore);
  147.       this.field_19 = this.field_16.stringWidth(this.dummyLevel);
  148.       this.prepareIntro();
  149.       this.runner = new Thread(this);
  150.       this.runner.start();
  151.    }
  152.  
  153.    public void prepareIntro() {
  154.       this.field_5.setColor(0, 0, 0);
  155.       this.field_5.fillRect(0, 0, this.field_14, this.field_15 - 9);
  156.       this.field_5.drawImage(this.imgs[25], (this.field_14 - 96) / 2, 11, 16 | 4);
  157.       this.field_5.setColor(255, 255, 255);
  158.       this.field_5.drawString(this.various[0], (this.field_14 - this.field_16.stringWidth(this.various[0])) / 2, 0, 16 | 4);
  159.       this.field_5.drawString(this.various[1], (this.field_14 - this.field_16.stringWidth(this.various[1])) / 2, 35, 16 | 4);
  160.       this.field_4.setClip(0, 0, this.field_14, this.field_15 - 9);
  161.       this.state = 10;
  162.       this.oldState = 10;
  163.       this.counter = 0;
  164.       ((Displayable)this).removeCommand(this.pauseCommand);
  165.       ((Displayable)this).addCommand(this.startCommand);
  166.    }
  167.  
  168.    public void resetGame() {
  169.       this.field_4.setClip(0, 0, this.field_14, this.field_15);
  170.       this.field_4.setColor(0, 0, 0);
  171.       ((Displayable)this).removeCommand(this.startCommand);
  172.       ((Displayable)this).addCommand(this.pauseCommand);
  173.  
  174.       for(this.field_0 = 0; this.field_0 < 6; ++this.field_0) {
  175.          this.scoreChars[this.field_0] = '0';
  176.       }
  177.  
  178.       this.lives = 2;
  179.       this.level = 1;
  180.       this.field_4.fillRect(0, this.field_15 - 9, this.field_14, 9);
  181.       this.field_4.drawImage(this.imgs[5], this.field_18 + 8, this.field_15 - 8, 16 | 4);
  182.       this.field_4.drawImage(this.imgs[5], this.field_18 + 18, this.field_15 - 8, 16 | 4);
  183.       this.resetMap();
  184.    }
  185.  
  186.    public void resetMap() {
  187.       for(this.field_0 = 0; this.field_0 < 930; ++this.field_0) {
  188.          int[] var10000 = this.map;
  189.          int var10001 = this.field_0;
  190.          var10000[var10001] &= 11;
  191.       }
  192.  
  193.       this.dots = 0;
  194.       this.field_5.drawImage(this.maze, 0, 0, 16 | 4);
  195.       this.field_4.setColor(0, 0, 0);
  196.       this.field_4.fillRect(this.field_14 - this.field_19 - 10, this.field_15 - 9, this.field_19 + 10, 9);
  197.       this.field_4.setColor(255, 255, 255);
  198.       this.levelChars[1] = (char)(48 + this.level % 10);
  199.       this.levelChars[0] = (char)(48 + this.level / 10 % 10);
  200.       this.field_4.drawChars(this.levelChars, 0, 2, this.field_14 - this.field_19, this.field_15 - this.field_17, 16 | 4);
  201.       this.field_4.drawImage(this.imgs[21 + (this.level + 3 & 3)], this.field_14 - this.field_19 - 10, this.field_15 - 8, 16 | 4);
  202.       this.resetMobiles();
  203.    }
  204.  
  205.    public void resetMobiles() {
  206.       this.state = 0;
  207.       this.counter = 0;
  208.       this.field_6 = 58;
  209.       this.field_7 = 92;
  210.       this.pLook = 4;
  211.       this.wantDir = 0;
  212.       this.pDir = 0;
  213.       this.pState = 0;
  214.       this.pCount = 20;
  215.  
  216.       for(this.field_0 = 0; this.field_0 < 4; ++this.field_0) {
  217.          this.sCount[this.field_0] = 0;
  218.       }
  219.  
  220.       for(this.field_0 = 0; this.field_0 < 3; ++this.field_0) {
  221.          this.gLook[this.field_0] = 8 + this.field_0;
  222.          this.field_11[this.field_0] = 56;
  223.          this.field_10[this.field_0] = 50 + 8 * this.field_0;
  224.          this.gDir[this.field_0] = 3 + (this.randi() & 1);
  225.          this.gCount[this.field_0] = 30 + 30 * this.field_0;
  226.          this.gState[this.field_0] = 0;
  227.       }
  228.  
  229.       if (this.map[541] + this.map[542] > 0) {
  230.          this.map[541] = 0;
  231.          this.map[542] = 0;
  232.          this.field_5.setColor(0, 0, 0);
  233.          this.field_5.fillRect(50, 66, 12, 8);
  234.       }
  235.  
  236.    }
  237.  
  238.    public int randi() {
  239.       this.seed = this.seed * 171 % 30269;
  240.       return this.seed;
  241.    }
  242.  
  243.    public void run() {
  244.       while(true) {
  245.          this.now = System.currentTimeMillis();
  246.          if (this.nextTime < this.now + 15L) {
  247.             this.nextTime = this.now + 15L;
  248.          }
  249.  
  250.          try {
  251.             Thread.sleep(this.nextTime - this.now);
  252.          } catch (Exception var6) {
  253.          }
  254.  
  255.          this.nextTime = System.currentTimeMillis() + 50L;
  256.          ++this.counter;
  257.          switch (this.state) {
  258.             case 0:
  259.                if ((this.counter & 255) == 255) {
  260.                   this.map[541] = 4;
  261.                   this.map[542] = 4;
  262.                   this.field_5.drawImage(this.imgs[21 + (this.level + 3 & 3)], 53, 66, 16 | 4);
  263.                }
  264.  
  265.                --this.pCount;
  266.                switch (this.pState) {
  267.                   case 0:
  268.                      if (this.pCount < 0) {
  269.                         this.pState = 1;
  270.                         this.field_6 = 56;
  271.                         this.wantDir = 3;
  272.                         this.field_5.setColor(0, 0, 0);
  273.                         this.field_5.fillRect(39, 67, 34, 6);
  274.                      }
  275.                      break;
  276.                   case 1:
  277.                      if ((this.field_6 & 3) + (this.field_7 & 3) == 0) {
  278.                         int var7 = (this.field_6 >> 2) + 31 * (this.field_7 >> 2);
  279.                         if (this.map[var7 + this.dPos[this.wantDir]] < 8) {
  280.                            this.pDir = this.wantDir;
  281.                         } else if (this.map[var7 + this.dPos[this.pDir]] > 7) {
  282.                            this.pDir = 0;
  283.                         }
  284.  
  285.                         this.field_5.setColor(0, 0, 0);
  286.                         if (this.map[var7] == 1) {
  287.                            ++this.dots;
  288.                            ++this.scoreChars[5];
  289.                            this.map[var7] = 5;
  290.                            this.field_5.fillRect(this.field_6 - 4, this.field_7, 4, 4);
  291.                         } else if (this.map[var7] == 2) {
  292.                            ++this.dots;
  293.                            ++this.scoreChars[4];
  294.                            this.map[var7] = 6;
  295.                            this.field_5.fillRect(this.field_6 - 4, this.field_7, 4, 4);
  296.                            this.pCount = 100;
  297.                            this.eatCount = 0;
  298.  
  299.                            for(int var13 = 0; var13 < 3; ++var13) {
  300.                               if (this.gState[var13] == 2) {
  301.                                  this.gState[var13] = 3;
  302.                                  this.gLook[var13] = 11;
  303.                               }
  304.                            }
  305.                         } else if (this.map[var7] == 4) {
  306.                            char[] var18 = this.scoreChars;
  307.                            var18[3] = (char)(var18[3] + this.bonuses[this.level & 3]);
  308.                            this.map[var7] = 0;
  309.                            this.map[var7 - 1] = 0;
  310.                            this.map[var7 + 1] = 0;
  311.                            this.field_5.fillRect(this.field_6 - 12, this.field_7 - 2, 20, 8);
  312.  
  313.                            int var12;
  314.                            for(var12 = 0; this.sCount[var12] > 0; ++var12) {
  315.                            }
  316.  
  317.                            this.sLook[var12] = 17 + (this.level + 3 & 3);
  318.                            this.sCount[var12] = 20;
  319.                            this.field_12[var12] = this.field_6;
  320.                            this.field_13[var12] = this.field_7;
  321.                         }
  322.  
  323.                         int var21 = var7 + this.dPos[this.pDir];
  324.                      }
  325.  
  326.                      this.field_6 += 2 * this.field_20[this.pDir];
  327.                      this.field_7 += 2 * this.field_21[this.pDir];
  328.                      if (this.field_6 < 0) {
  329.                         this.field_6 += 120;
  330.                      } else if (this.field_6 > 119) {
  331.                         this.field_6 -= 120;
  332.                      }
  333.  
  334.                      if (this.pDir > 0) {
  335.                         this.pLook = this.pDir * 2 - 2 + (this.counter & 1);
  336.                      }
  337.  
  338.                      if (this.dots == 244) {
  339.                         this.state = 2;
  340.                         this.pCount = 45;
  341.                      }
  342.                }
  343.  
  344.                for(int var8 = 0; var8 < 3; ++var8) {
  345.                   switch (this.gState[var8]) {
  346.                      case 0:
  347.                         int[] var31 = this.field_10;
  348.                         var31[var8] += 4 * this.gDir[var8] - 14;
  349.                         if (this.field_10[var8] < 50 || this.field_10[var8] > 66) {
  350.                            var31 = this.field_10;
  351.                            var31[var8] -= 8 * this.gDir[var8] - 28;
  352.                            this.gDir[var8] = 7 - this.gDir[var8];
  353.                         }
  354.  
  355.                         int var10002 = this.gCount[var8]--;
  356.                         if (this.gCount[var8] < 0 && this.field_10[var8] == 58) {
  357.                            this.gState[var8] = 1;
  358.                            this.gDir[var8] = 1;
  359.                         }
  360.                         break;
  361.                      case 1:
  362.                         int[] var29 = this.field_11;
  363.                         var29[var8] += 4 * this.gDir[var8] - 6;
  364.                         if (this.field_11[var8] == 44) {
  365.                            this.gState[var8] = 2;
  366.                            this.gDir[var8] = 3 + (this.pDir & 1);
  367.                            var29 = this.field_10;
  368.                            var29[var8] += 4 * this.gDir[var8] - 14;
  369.                         } else if (this.field_11[var8] == 56) {
  370.                            this.gCount[var8] = 30;
  371.                            this.gLook[var8] = 8 + var8;
  372.                            this.gDir[var8] = 3 + (this.counter & 1);
  373.                            this.gState[var8] = 0;
  374.                         }
  375.                         break;
  376.                      case 2:
  377.                      case 3:
  378.                      case 4:
  379.                         if (this.gState[var8] == 2) {
  380.                            this.speed = 2;
  381.                            this.targetX = this.field_6;
  382.                            this.targetY = this.field_7;
  383.                            this.randomness = 15;
  384.                         } else if (this.gState[var8] == 3) {
  385.                            this.speed = 1;
  386.                            this.targetX = 2 * this.field_10[var8] - this.field_6;
  387.                            this.targetY = 2 * this.field_11[var8] - this.field_7;
  388.                            this.randomness = 0;
  389.                            if (this.pCount < 20) {
  390.                               this.gLook[var8] = 11 + (this.counter & 1);
  391.                            } else {
  392.                               this.gLook[var8] = 11;
  393.                            }
  394.                         } else {
  395.                            this.speed = 4;
  396.                            this.targetX = 58;
  397.                            this.targetY = 44;
  398.                         }
  399.  
  400.                         if ((this.field_10[var8] & 3) + (this.field_11[var8] & 3) == 0) {
  401.                            this.bestVal = 0;
  402.                            this.bestDir = 0;
  403.                            int var14 = (this.field_10[var8] >> 2) + 31 * (this.field_11[var8] >> 2);
  404.                            if (this.map[var14 - 31] < 8 && this.gDir[var8] != 2) {
  405.                               this.bestVal = 50;
  406.                               this.bestDir = 1;
  407.                               if (this.targetY < this.field_11[var8]) {
  408.                                  this.bestVal += (this.randi() & this.randomness) + 1;
  409.                               }
  410.                            }
  411.  
  412.                            if (this.map[var14 + 31] < 8 && this.gDir[var8] != 1) {
  413.                               int var3 = 50;
  414.                               if (this.targetY > this.field_11[var8]) {
  415.                                  var3 += (this.randi() & this.randomness) + 1;
  416.                               }
  417.  
  418.                               if (var3 > this.bestVal) {
  419.                                  this.bestDir = 2;
  420.                                  this.bestVal = var3;
  421.                               }
  422.                            }
  423.  
  424.                            if (this.map[var14 - 1] < 8 && this.gDir[var8] != 4) {
  425.                               int var16 = 50;
  426.                               if (this.targetX < this.field_10[var8]) {
  427.                                  var16 += (this.randi() & this.randomness) + 1;
  428.                               }
  429.  
  430.                               if (var16 > this.bestVal) {
  431.                                  this.bestDir = 3;
  432.                                  this.bestVal = var16;
  433.                               }
  434.                            }
  435.  
  436.                            if (this.map[var14 + 1] < 8 && this.gDir[var8] != 3) {
  437.                               int var17 = 50;
  438.                               if (this.targetX > this.field_10[var8]) {
  439.                                  var17 += (this.randi() & this.randomness) + 1;
  440.                               }
  441.  
  442.                               if (var17 > this.bestVal) {
  443.                                  this.bestDir = 4;
  444.                               }
  445.                            }
  446.  
  447.                            this.gDir[var8] = this.bestDir;
  448.                            if (this.gState[var8] == 3 && this.pCount < 0) {
  449.                               this.gState[var8] = 2;
  450.                               this.gLook[var8] = 8 + var8;
  451.                               this.speed = 2;
  452.                            } else if (this.gState[var8] == 4 && this.field_11[var8] == 44 && (this.field_10[var8] == 56 || this.field_10[var8] == 60)) {
  453.                               this.field_10[var8] = 58;
  454.                               this.gState[var8] = 1;
  455.                               this.gDir[var8] = 2;
  456.                            }
  457.                         }
  458.  
  459.                         int[] var22 = this.field_10;
  460.                         var22[var8] += this.speed * this.field_20[this.gDir[var8]];
  461.                         var22 = this.field_11;
  462.                         var22[var8] += this.speed * this.field_21[this.gDir[var8]];
  463.                         if (this.field_10[var8] < 0) {
  464.                            var22 = this.field_10;
  465.                            var22[var8] += 120;
  466.                         } else if (this.field_10[var8] > 119) {
  467.                            var22 = this.field_10;
  468.                            var22[var8] -= 120;
  469.                         }
  470.  
  471.                         if (this.field_10[var8] < this.field_6 + 8 && this.field_10[var8] > this.field_6 - 8 && this.field_11[var8] < this.field_7 + 8 && this.field_11[var8] > this.field_7 - 8) {
  472.                            if (this.gState[var8] != 3) {
  473.                               if (this.gState[var8] == 2) {
  474.                                  this.state = 3;
  475.                                  this.counter = -1;
  476.                               }
  477.                            } else {
  478.                               this.gLook[var8] = 13;
  479.                               this.gState[var8] = 4;
  480.                               var22 = this.field_10;
  481.                               var22[var8] &= 252;
  482.                               var22 = this.field_11;
  483.                               var22[var8] &= 252;
  484.                               ++this.eatCount;
  485.                               char[] var28 = this.scoreChars;
  486.                               var28[3] = (char)(var28[3] + this.bonuses[this.eatCount]);
  487.  
  488.                               int var15;
  489.                               for(var15 = 0; this.sCount[var15] > 0; ++var15) {
  490.                               }
  491.  
  492.                               this.sLook[var15] = 17 + this.eatCount;
  493.                               this.sCount[var15] = 20;
  494.                               this.field_12[var15] = this.field_6;
  495.                               this.field_13[var15] = this.field_7;
  496.                            }
  497.                         }
  498.                   }
  499.                }
  500.  
  501.                this.field_4.setClip(0, 0, this.field_14, this.field_15 - 9);
  502.                if (this.field_14 < 112) {
  503.                   this.field_8 = 50 - this.field_6;
  504.                   if (this.field_8 > 0) {
  505.                      this.field_8 = 0;
  506.                   } else if (this.field_8 < this.field_14 - 112) {
  507.                      this.field_8 = this.field_14 - 112;
  508.                   }
  509.                }
  510.  
  511.                if (this.field_15 < 133) {
  512.                   this.field_9 = 51 - this.field_7;
  513.                   if (this.field_9 > 0) {
  514.                      this.field_9 = 0;
  515.                   } else if (this.field_9 < this.field_15 - 133) {
  516.                      this.field_9 = this.field_15 - 133;
  517.                   }
  518.                }
  519.  
  520.                this.field_4.drawImage(this.mazebuf, this.field_8, this.field_9, 16 | 4);
  521.  
  522.                for(int var9 = 0; var9 < 4; ++var9) {
  523.                   if (this.sCount[var9] > 0) {
  524.                      int var35 = this.sCount[var9]--;
  525.                      this.field_4.drawImage(this.imgs[this.sLook[var9]], this.field_12[var9] + this.field_8 + this.offsX[this.sLook[var9]], this.field_13[var9] + this.field_9 + this.offsY[this.sLook[var9]], 16 | 4);
  526.                   }
  527.                }
  528.  
  529.                this.field_4.drawImage(this.imgs[this.pLook], this.field_6 + this.field_8 + this.offsX[this.pLook], this.field_7 + this.field_9 + this.offsY[this.pLook], 16 | 4);
  530.  
  531.                for(int var10 = 0; var10 < 3; ++var10) {
  532.                   this.field_4.drawImage(this.imgs[this.gLook[var10]], this.field_10[var10] + this.field_8 + this.offsX[this.gLook[var10]], this.field_11[var10] + this.field_9 + this.offsY[this.gLook[var10]], 16 | 4);
  533.                }
  534.  
  535.                this.field_4.setClip(0, 0, this.field_14, this.field_15);
  536.  
  537.                for(int var11 = 5; var11 > 0; --var11) {
  538.                   if (this.scoreChars[var11] > '9') {
  539.                      char[] var33 = this.scoreChars;
  540.                      var33[var11] = (char)(var33[var11] - 10);
  541.                      ++this.scoreChars[var11 - 1];
  542.                   }
  543.                }
  544.  
  545.                if ((this.counter & 1) == 0) {
  546.                   this.field_4.setColor(0, 0, 0);
  547.                   this.field_4.fillRect(1, this.field_15 - 9, this.field_18, 9);
  548.                   this.field_4.setColor(255, 255, 255);
  549.                   this.field_4.drawChars(this.scoreChars, 1, 5, 1, this.field_15 - this.field_17, 16 | 4);
  550.                }
  551.             case 1:
  552.             case 5:
  553.             case 6:
  554.             case 7:
  555.             case 8:
  556.             case 9:
  557.             default:
  558.                break;
  559.             case 2:
  560.                this.pLook = this.pLook & 254 | this.pCount-- & 1;
  561.                this.field_4.drawImage(this.imgs[this.pLook], this.field_6 + this.field_8 + this.offsX[this.pLook], this.field_7 + this.field_9 + this.offsY[this.pLook], 16 | 4);
  562.                if (this.pCount == 0) {
  563.                   ++this.level;
  564.                   ++this.scoreChars[2];
  565.                   this.resetMap();
  566.                }
  567.                break;
  568.             case 3:
  569.                this.field_4.setClip(0, 0, this.field_14, this.field_15 - 9);
  570.                this.field_4.drawImage(this.mazebuf, this.field_8, this.field_9, 16 | 4);
  571.                if (this.counter < 6) {
  572.                   this.pLook = 14 + this.counter / 2;
  573.                   this.field_4.drawImage(this.imgs[this.pLook], this.field_6 + this.field_8 + this.offsX[this.pLook], this.field_7 + this.field_9 + this.offsY[this.pLook], 16 | 4);
  574.                }
  575.  
  576.                if (this.counter > 30) {
  577.                   --this.lives;
  578.                   if (this.lives < 0) {
  579.                      this.field_4.drawImage(this.imgs[26], (this.field_14 - 54) / 2, this.field_15 / 2 - 5, 16 | 4);
  580.                      this.state = 4;
  581.                   } else {
  582.                      this.field_4.setClip(0, 0, this.field_14, this.field_15);
  583.                      this.field_4.setColor(0, 0, 0);
  584.                      this.field_4.fillRect(this.field_18 + 8 + 10 * this.lives, this.field_15 - 8, 8, 8);
  585.                      this.resetMobiles();
  586.                   }
  587.                }
  588.                break;
  589.             case 4:
  590.                if (this.counter > 70) {
  591.                   this.prepareIntro();
  592.                }
  593.                break;
  594.             case 10:
  595.                this.field_4.drawImage(this.mazebuf, 0, 0, 16 | 4);
  596.                int var1 = this.counter & 63;
  597.                int var2 = this.counter / 64;
  598.                if (var2 < 3) {
  599.                   this.field_4.drawImage(this.imgs[8 + var2], var1 + this.field_14 / 2 - 64, 49 + 11 * var2, 16 | 4);
  600.                   if (var1 == 63) {
  601.                      this.field_5.drawImage(this.imgs[8 + var2], var1 + this.field_14 / 2 - 64, 49 + 11 * var2, 16 | 4);
  602.                      this.field_5.drawString(this.various[2 + var2], this.field_14 / 2 + 10, 46 + 11 * var2, 16 | 4);
  603.                   }
  604.                } else if (var1 == 63) {
  605.                   this.prepareIntro();
  606.                }
  607.  
  608.                if ((this.counter & 32) == 0) {
  609.                   this.field_4.drawImage(this.imgs[6 + (this.counter & 1)], this.field_14 / 2 - 36 + 2 * (this.counter & 31), this.field_15 - 17, 16 | 4);
  610.                } else {
  611.                   this.field_4.drawImage(this.imgs[4 + (this.counter & 1)], this.field_14 / 2 + 28 - 2 * (this.counter & 31), this.field_15 - 17, 16 | 4);
  612.                }
  613.          }
  614.  
  615.          ((Canvas)this).repaint(this.field_22, this.field_23, this.field_14, this.field_15);
  616.          ((Canvas)this).serviceRepaints();
  617.       }
  618.    }
  619.  
  620.    public void resume() {
  621.       this.state = this.oldState;
  622.       if (this.oldState == 10) {
  623.          this.resetGame();
  624.       }
  625.  
  626.       ((Displayable)this).removeCommand(this.startCommand);
  627.       ((Displayable)this).addCommand(this.pauseCommand);
  628.    }
  629.  
  630.    public void pause() {
  631.       this.oldState = this.state;
  632.       this.state = 9;
  633.       ((Displayable)this).removeCommand(this.pauseCommand);
  634.       ((Displayable)this).addCommand(this.startCommand);
  635.    }
  636.  
  637.    protected void keyPressed(int var1) {
  638.       switch (((Canvas)this).getGameAction(var1)) {
  639.          case 1:
  640.             this.wantDir = 1;
  641.             break;
  642.          case 2:
  643.             this.wantDir = 3;
  644.          case 3:
  645.          case 4:
  646.          default:
  647.             break;
  648.          case 5:
  649.             this.wantDir = 4;
  650.             break;
  651.          case 6:
  652.             this.wantDir = 2;
  653.       }
  654.  
  655.    }
  656.  
  657.    public void paint(Graphics var1) {
  658.       if (var1.getClipX() < this.field_22 || var1.getClipWidth() > this.field_14 || var1.getClipY() < this.field_23 || var1.getClipHeight() > this.field_15) {
  659.          var1.setColor(0);
  660.          var1.fillRect(0, 0, ((Canvas)this).getWidth(), ((Canvas)this).getHeight());
  661.       }
  662.  
  663.       var1.drawImage(this.buf, this.field_22, this.field_23, 16 | 4);
  664.    }
  665. }
  666.